package com.xayy.health.core.config.datasource;

/**
 * 数据源设置l
 *
 * @author dongxingli
 * createTime 2021/2/25
 * @version V1.0
 */
public class DatasourceHolder {

    private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();

    /**
     * 设置数据源
     *
     * @param name
     */
    public static void changeSource(String name) {
        CONTEXT_HOLDER.set(name);
    }

    /**
     * 取得当前数据源
     *
     * @return
     */
    public static String getSource() {
        return CONTEXT_HOLDER.get();
    }

    /**
     * 清除上下文数据
     */
    public static void clearSource() {
        CONTEXT_HOLDER.remove();
    }
}
